
using System;
using System.Collections;
using System.Web.UI.WebControls;

namespace GiftNet.Model
{
	#region CustomDetail Model -(by fangyifeng at 2007-09-14 12:23:59)

	/// <summary>
	/// CustomDetail object'CustomDetail'.
	/// </summary>
	[Serializable]
	public class CustomDetail : System.IComparable
		{
		#region Member Variables
		
		protected Guid _id;
		protected short _noticeWay;
		protected DateTime _onDate;
		protected CustomHead _customHead;
		protected CustomItem _customItem;
		
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public CustomDetail() { }

		public CustomDetail( short noticeWay, DateTime onDate, CustomHead customHead, CustomItem customItem )
		{
			this._noticeWay = noticeWay;
			this._onDate = onDate;
			this._customHead = customHead;
			this._customItem = customItem;
		}

		#endregion

		#region Public Properties

		public virtual Guid Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public virtual short NoticeWay
		{
			get { return _noticeWay; }
			set { _noticeWay = value; }
		}

		public virtual DateTime OnDate
		{
			get { return _onDate; }
			set { _onDate = value; }
		}

		public virtual CustomHead CustomHead
		{
			get { return _customHead; }
			set { _customHead = value; }
		}

		
		public virtual CustomItem CustomItem
		{
			get { return _customItem; }
			set { _customItem = value; }
		}

		
        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public virtual int CompareTo(object obj)
        {
			if (!(obj is CustomDetail))
				throw new InvalidCastException("This object is not of type CustomDetail");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((CustomDetail)obj).Id);
					break;
				case "NoticeWay":
					relativeValue = this.NoticeWay.CompareTo(((CustomDetail)obj).NoticeWay);
					break;
				case "OnDate":
					relativeValue = this.OnDate.CompareTo(((CustomDetail)obj).OnDate);
					break;
                default:
                    goto case "Id";
			}
            if (CustomDetail.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
